In this paper, the methods used by the DateTime object are collated to make it easy for us to find and flip through, so we can refer to learning.
Objective
The instantiation object is preceded by \ means that the native class is used in the
Objective
The instantiation object is preceded by the use of the native class in the namespace, and if the namespace is not used, the preceding \ can be deleted
1. Output Current time
$datetime = new \datetime;
Print_r ($datetime->format ('
Manual Address: http://php.net/manual/en/dateinterval.format.php1 $january=NewDateTime (' 2010-01-01 ');2 $february=NewDateTime (' 2010-02-01 ');3 $interval=$january->diff ($february);4 5 //%a would output the total number of days.6 Echo $interval-
Converts datetime to Chinese. The following is a method for converting datetime to adult, month, day, hour, minute, and second. For more information, see. The following is a conversion of datetime date and time to adult \ ', \ 'months \', \ 'Day \ ',
Unix epoch Time, also known as POSIX time/epoch time, is the total number of seconds from 0 seconds from January 1, 1970 0:0 UTC to the present, excluding leap seconds. A positive value represents 1970, and a negative value indicates before
The following is a datetime date time conversion adult \ ', \ ' months \ ', \ ' days \ ', \ ' hours \ ', \ ' sub-species \ ', \ ' s \ ' to show that the need for friends can refer to.
The following is a datetime date time conversion to adulthood ', '
The following is a conversion of datetime date and time to adult \ ', \ 'months \', \ 'day \ ', \ 'hour \', \ 'sub-type \', \ 'Seconds \ 'to display. For more information, see.
The following example shows how to convert datetime to adult, month, day,
Copy CodeThe code is as follows:
/**
* Friendly Date and time
*
* Date Time @param datetime $datetime
* @param int $size Precise in-place number
* @throws \invalidargumentexception
* @return String
*/
function Friendly_date ($datetime, $size
Convert DateTime object to friendly time display
Convert DateTime objects to friendly time display using DateInterval in PHP 5.x
/**
* Friendly date and time
*
* @ Param DateTime $ datetime date and time
*
Convert a DateTime object to a friendly time display using DateInterval in PHP 5.x
/**
* Friendly Date and time
*
* Date Time @param datetime $datetime
* @param int $size Precise in-place number
* @throws
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.